\section{Design}
\label{design}
The design of ATCP is based on the analysis of weighted TCP in previous section. The goal of ATCP is to make bandwidth allocation preferable to small flows while maintaining networks' high utilization. ATCP sends data and measures data size simulatenously, and introduce a weight-size function. ATCP achieves perference to small flows by setting a higher weight for them; the weight-size function decreases as ATCP sends data saving the trouble to distinguish large and small flows; it achieves high utilization by keeping the AIMD scheme; and this involves only small changes in kernel's protocol stack, which is independent to hardware/application/network changes.

The idea of weighted TCP is also used by some other endhost-based rate control such as seawall~\cite{seawall}. The key contribution is introduction of weight-size function which measures teh size of data as soon as it is sent. The weight-size funtion needs to meet with some principles to guarantee the actual bandwidth allocation satisfy the requirements.
\subsection{A sample example}
%\begin{figure}
%\centering
%\begin{tabular}{cc}
%\includegraphics[width=3in]{fig/tcp_theo.pdf} &
%\includegraphics[width=3in]{fig/atcp_theo.pdf}\\
%(a) & (b)
%\end{tabular}
%\caption{Theoretical Throughput in 2-Flow Senario}
%\label{fig:2flow:theo}
%\end{figure}
\begin{figure}
\centering
\begin{tabular}{cc}
\includegraphics[width=1.5in]{fig/tcp_rate.pdf} &
\includegraphics[width=1.5in]{fig/atcp_rate.pdf}\\
(a) & (b)
\end{tabular}
\caption{Simulation Throughput in 2-Flow Senario}
\label{fig:2flow:simu}
\end{figure}
Based on theoretical analysis in previous section, we start with simple 2-flow example. A large flow starts first followed by a small flow and they share a link in the network. According to TCP's fairness, each of them will finally converge to half of the link's capacity. As is shown in Figure~\ref{fig:2flow:theo}(a). If we increase small flow's weight to $a$ and decrease large flow's weight to $b$ $(a>b)$, the expected bandwidth ratio is $a:b$, as is shown in Figure~\ref{fig:2flow:theo}(b). Comparing ATCP with TCP, we find that in ATCP the small flow get more bandwidth in its duration; in both cases the small flow sends the same size of data (the size is the area between the flow's curve and X-axis), so the small flow completes more quickly compared with TCP. Since the two flows always saturate the link, the end time of all the flows are $\frac{total\_flow\_size}{link\_capacity}$, which means the large flows also complete at the same time. That is, in ATCP, the small flows get more bandwidth and completes more quickly than TCP. The large flows get compensated in time when small flows complete and they take the same time to complete like a large TCP flow.

We simulate this 2-flow senario and get Figure ~\ref{fig:2flow:simu}, in which we use a simple chain topology with 100Mbps bandwidth and 200us total delay, the large flow is 100MB and the small flow is 1MB; we set the large flow with weight 1 and small flow with 2. We find that although there are ocsillations in slow start phase, after the flow gets into congestion avoidance phase the result is similar to our analysis. First, the small flow and large flow bandwidth allocation is 2:1. Second, the link utilization is more than 90\%. Third, small flows complete more quickly in ATCP, while large flow completes almost at the same time.
\subsection{Adaptive Bandwidth Allocation}
Bandwidth allocation should be adaptive to flow size. The allocation is determined by the flow's weight according to section~\ref{weight}. The flow size can be obtained by measurement as it sends data. So we introduce a weight-size function. In this function, weight is large when the sent data size is small, and then decreases as sent data size increases. That is, for each flow the first few bytes are sent with higher rate and the last few bytes are sent with lower weight. The function is the same for all flows in the data center. For small flows, their weights are relatively high in their duration; for large flow, only the first few bytes are sent with higher weight and most of their bytes are sent in low rate. When a small flow competes with a large flow, it is quite possible that the small flow has a higher weight than large flow, so that small flow can get more bandwidth.

The weight-size function needs to be designed carefully. It should be designed in such a way that it gives preference to small flows and achieves high utilization. We discuss the principles and design of weight-size function in the next section and figure out the parameters we need in tuning this function.
\subsection{Weight Function}
%\begin{figure}
%\centering
%\begin{tabular}{cc}
%\includegraphics[width=3in]{fig/fig_large_small.pdf} &
%\includegraphics[width=3in]{fig/fig_small_large.pdf}\\
%(a) & (b)
%\end{tabular}
%\caption{Expentional Decreasing Weight Function}
%\label{fig:exp}
%\end{figure}
%\begin{figure}
%\centering
%\begin{tabular}{cc}
%\includegraphics[width=3in]{fig/fig_large_small_frag.pdf} &
%\includegraphics[width=3in]{fig/fig_small_large_frag.pdf}\\
%(a) & (b)
%\end{tabular}
%\caption{Fragmental Constant-Exponential Weight Function}
%\label{fig:frag}
%\end{figure}
To satisfy the requirements, the weight-size function should meet three conditions. First, the weight-size function should be non-increasing. This ensures small flows get higher weight than large flows. Second, the weight-size function should be positive, so that congestion window will increase to saturate the network in case there is available bandwidth in the network. Third, the average weight should not be too small or too large. Small weight means longer convergence time and large weight can cause oscillation in throughput.

We first propose an exponentially decreasing function such as $$Weight=(W_H-W_L)\times e^{-\alpha\times size}+W_L,$$ to satisfy the first condition. The second and the third conditions can be satisfied by tuning the parameters; but it cannot guarantee a small flow have a larger weight than a large flow always. We compare a large flow and a small flow in three situations. Suppose a large flow and a small flow overlap with each other. If large flow starts first, in all its duration, smaller flows weight is larger than large flow(Figure~\ref{fig:exp}(a)); if they start at the same time, the large flow and the small flow will have the same weight in the whole duration; if the small flow start first, the large flow will always have a larger weight than small flow. Considering the duration of large flow and small flow, the last situation will happen in low probability, but in this case the small flow's performance will degrade. We can still improve the function to avoid it.

We propose a constant-exponential fragmental weight-size function
$$
W=\left\{
        \begin{array}{ll}
        W_H & \mbox{if $s\leq T$ } \\
        (W_H-W_L)\times e^{-\alpha\times (s-T)}+W_L & \mbox{ otherwise }
        \end{array}
        \right.
,$$ where $W$ is weight, $s$ is sent data size and $T$ is bound between small and large flow.
Consider the PDF of flow size distribution, there is a large gap between large flows and small flows, so we can easily define a threshold as the bound to define small and large flows. In all durations of the small flow, it always gets the highest value. Consider the large and small flow senario, if the large flow starts first, small flow will always get a non-smaller weight; otherwise, both of them get the same weight. So the small flow gets higher weight resulting in the reduction of the completion time; in few cases it get the same weight with large flow in which its performance is no worse than TCP.

The parameter in this weight-size function is $W_H$, $W_L$, Threshold, $\alpha$, which are the upper bound, lower bound, large/small flow bound, and tuning paramter respectively. By tuning these parameters, the weight-size function can satisfy the principle 2 and 3. We study their influence on performance in section~\ref{eval}.




